<!DOCTYPE html>
<html>

	<head>
		<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
		<link rel="stylesheet" href="__STATIC__/admin/css/ionicons.min.css">
		<link rel="stylesheet" href="__STATIC__/admin/css/animate.min.css">
		<link rel="stylesheet" href="__STATIC__/admin/css/bootstrap.min.css">
		<link rel="stylesheet" href="__STATIC__/admin/css/bootstrapreset.css">
		<link rel="stylesheet" href="__STATIC__/admin/css/responsive.css">
		<link rel="stylesheet" href="__STATIC__/admin/css/common.css">
		<script src="__STATIC__/admin/js/jquery.min.js"></script>
		<script src="__STATIC__/admin/lib/layui/layui.js" charset="utf-8"></script>
	</head>

	<body class="login-body pxgridsbody">
		<div class="container">
			<form action="" class="form-signin animated fadeInDown" onsubmit="return false" id="login">
				<div class="form-signin-heading center">
					用户登录
				</div>
				<div class="login-wrap">
					<div class="loginlogo center"><img src="__STATIC__/admin/images/login_logo.png" alt=""></div>
					<div class="form-group">
						<div class="input-group">
							<div class="input-group-addon">
								<i class="ion-person"></i>
							</div>
							<input type="text" class="form-control" name="username" required placeholder="请填写用户名">
						</div>
					</div>
					<div class="form-group">
						<div class="input-group">
							<div class="input-group-addon">
								<i class="ion-locked"></i>
							</div>
							<input type="password" autocomplete="new-password" class="form-control" name="password" required placeholder="请输入密码">
						</div>
					</div>
					<div class="form-group">
						<div id="captcha"></div>
						<p id="wait" class="show">正在加载验证码......</p>
						<p id="notice" class="hide">请先完成验证</p>
					</div>
					<input type="submit" class="btn btn-shadow btn-success btn-block btn-login" value="登录" id="btn">
				</div>
				<div class="form-signin-bottom center">
					Copyright © 2019-2022 校朋教育 提供技术支持
				</div>
			</form>
		</div>
		<script src="__STATIC__/admin/js/gt.js"></script>
		<script type="text/javascript">
			layui.use('table', function(){
				$(function() {
					//极验验证
					$.ajax({
						url: "{:url('bancard/Login/geet_code')}?t=" + (new Date()).getTime(), // 加随机数防止缓存
						type: "get",
						dataType: "json",
						success: function(data) {
							initGeetest({
								gt: data.gt,
								challenge: data.challenge,
								offline: !data.success,
								new_captcha: data.new_captcha,
								product: "embed"
							}, handlerEmbed);
						}
					});
					//极验回调
					var handlerEmbed = function(captchaObj) {
						$("#btn").click(function(e) {
							var validate = captchaObj.getValidate();
							if (!validate) {
								$("#notice")[0].className = "show";
								setTimeout(function() {
									$("#notice")[0].className = "hide";
								}, 2000);
								e.preventDefault();
							} else {
								var username = $("input[name='username']").val();
								var password = $("input[name='password']").val();
								if (username.length<5 || password.length<2) {
									layer.msg("账号或者密码不能为空", {
										'icon': 2,
										"time": 2000
									});
									return false;
								}
								$.ajax({
									url: "{:url('bancard/Login/index')}",
									type: "post",
									dataType: "json",
									data: {
										username: username,
										password: password
									},
									success: function(data) {
										if (data.status == 0) {
											layer.msg(data.message, {
												'icon': 1,
												"time": 500
											},function(){
												location.href = "{:url('bancard/index/index')}"
											});
											
										} else {
											layer.msg(data.message, {
												'icon': 2,
												"time": 2000
											});
										}
									}
								})
							}
						});
						captchaObj.appendTo("#captcha");
						captchaObj.onReady(function() {
							$("#wait")[0].className = "hide";
						});
					};
				})
			})
			
		</script>
	</body>

</html>
